//
//  PersonalInformationCell.m
//  OnionHome
//
//  Created by fengjie on 2019/9/14.
//  Copyright © 2019 FengJie. All rights reserved.
//

#import "PersonalInformationCell.h"

@interface PersonalInformationCell ()
/**左边文字*/
@property (nonatomic,strong)UILabel*leftName;
/**右边文字*/
@property (nonatomic,strong)UILabel*rightName;
/**右边图片*/
@property (nonatomic,strong)UIImageView*rightImage;
/**<#属性#>*/
//@property (nonatomic,strong)UIImageView * moreImage;
@end

@implementation PersonalInformationCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self createUI];
    }
    return self;
}
-(void)setIndexPath:(NSIndexPath *)indexPath{
    _indexPath = indexPath;
    if (indexPath.row == 0) {
        self.rightImage.hidden = NO;
        self.rightName.hidden = YES;
    }else{
        self.rightImage.hidden = YES;
        self.rightName.hidden = NO;
    }
    
//    if (indexPath.row == 5) {
//        self.moreImage.hidden = YES;
//    }else{
//        self.moreImage.hidden =NO;
//    }
}
-(void)setDic:(NSDictionary *)dic{
    self.leftName.text = dic[@"leftName"];
    self.rightName.text = dic[@"rightName"];
    self.rightImage.image = dic[@"rightImage"];
}
-(void)createUI{
//    self.moreImage = [[UIImageView alloc] initWithImage:IMAGE_NAMED(@"more")];

    [self addSubview:self.leftName];
    [self addSubview:self.rightName];
    [self addSubview:self.rightImage];
//    [self addSubview:self.moreImage];
    
    [self.leftName mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(16);
        make.top.mas_equalTo(37);
        make.bottom.mas_equalTo(-37);
    }];
    
    [self.rightName mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self.leftName);
        make.right.mas_equalTo(-36);
        make.left.mas_equalTo(100);
    }];
    
    [self.rightImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self.leftName);
        make.right.mas_equalTo(-36);
        make.width.height.mas_equalTo(32);
    }];
    
//    [self.moreImage mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.centerY.mas_equalTo(self.leftName);
//        make.right.mas_equalTo(-16);
//        make.width.mas_equalTo(7);
//        make.height.mas_equalTo(9);
//    }];
}
#pragma mark ---懒加载

-(UILabel*)leftName{
    if(!_leftName){
        _leftName=[UILabel new];
        _leftName.textColor = UIColorFromRGB(0x273323);
        _leftName.font = PingFangSC_Regular(18);
        _leftName.text = @"头像";
    }
    return _leftName;
}
-(UIImageView*)rightImage{
    if(!_rightImage){
        _rightImage=[UIImageView new];
        _rightImage.image = IMAGE_NAMED(@"userIconDefut");
        _rightImage.layer.cornerRadius = 16;
        _rightImage.layer.masksToBounds=YES;
        
    }
    return _rightImage;
}
-(UILabel*)rightName{
    if(!_rightName){
        _rightName=[UILabel new];
        _rightName.textColor = UIColorFromRGB(0x959E97);
        _rightName.font = PingFangSC_Regular(16);
        _rightName.text = @"我是一个购物狂";
        _rightName.textAlignment = NSTextAlignmentRight;
        _rightName.numberOfLines = 2;
    }
    return _rightName;
}

@end

